﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Data.Entity;
using System.Net;
using InternetCatalog.Models;

namespace InternetCatalog.Controllers
{
    public class HomeController : Controller
    {
        public ActionResult Index()
        {
            return View();
        }

          public ActionResult About()
        {
            ViewBag.Message = "Your application description page.";

            return View();
        }

        public ActionResult Contact()
        {
            ViewBag.Message = "Your contact page.";

            return View();
        }
//    }
//}




        public ActionResult FileUpload(HttpPostedFileBase file)
        {

            if (file != null)
            {
                //Database1Entities db = new Database1Entities();
                MeMeDBContext db = new MeMeDBContext();
                string ImageName = System.IO.Path.GetFileName(file.FileName);
                string physicalPath =Server.MapPath("~/lm2/"+ ImageName);

                // save image in folder
                //file.SaveAs(physicalPath);
                //db.Images.(physicalPath);
                db.SaveChanges();

                //save new record in database
                MeMe newRecord = new MeMe();

        //public int ID { get; set; }
        //public string Title { get; set; }
        //public string ImageURL { get; set; }
        //public string Description { get; set; }
        //public string Genre { get; set; }


                newRecord.Title = Request.Form["Title"];
                newRecord.ImageURL = Request.Form["ImageURL"];
                newRecord.Description = Request.Form["Description"];
                newRecord.Genre = Request.Form["Genre"];
                //db.tblAs.Add(newRecord);
                db.Images.Add(newRecord);
                db.SaveChanges();

            }
            //Display records
        return RedirectToAction("../MeMes/FullList/");
    }

public ActionResult FullList()
{
    return View();
}
}
}


      